package tt.dz.biz.task;

import tt.dz.biz.service.task.DailyTaskService;
import tt.dz.common.AppContxtUtil;
import tt.dz.common.LogUtil;

public class DailyDealTask
{
  private String jobCode;
  private DailyTaskService dailyTaskService;
  
  public void setJobCode(String jobCode)
  {
    this.jobCode = jobCode;
  }
  
  public String getJobCode()
  {
    return this.jobCode;
  }
  
  public DailyDealTask(String jobCode)
  {
    this.jobCode = jobCode;
  }
  
  public void executeTask()
    throws Exception
  {
    try
    {
      this.dailyTaskService = getDailyService();
      this.dailyTaskService.execute();
    }
    catch (Exception e)
    {
      LogUtil.error(this.jobCode + "任务执行失败，", e);
      throw e;
    }
  }
  
  protected DailyTaskService getDailyService()
  {
    DailyTaskService dailyTaskService = (DailyTaskService)AppContxtUtil.getBean(this.jobCode);
    return dailyTaskService;
  }
}
